package org.poem.controller;

import com.google.gson.Gson;
import org.poem.properties.CreaterUserInfoSetting;
import org.poem.properties.RedisConfigSetting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by poem on 2017/8/30.
 */
@RestController
@RequestMapping("/properties")
public class PropertiesController {

    @Value("${project.creater.name}")
    private String name;

    @Autowired
    private CreaterUserInfoSetting createrUserInfoSetting;

    @Autowired
    private RedisConfigSetting redisConfigSetting;

    @RequestMapping("/createUserName")
    public @ResponseBody String getUserName(){
        return  name;
    }

    @RequestMapping("/userInfoSetting")
    public @ResponseBody String userInfoSetting(){
        return createrUserInfoSetting.getName() + "\t" + createrUserInfoSetting.getProfession();
    }

    @RequestMapping("/otherProperties")
    public @ResponseBody String getOtherPro(){
        return new Gson().toJson(redisConfigSetting);
    }
}
